﻿using Blazui.Component;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Project13776616780_01.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Project13776616780_01.Pages.Adv
{
    public partial class Update
    {
        private BForm form;
        [Inject]
        private DocsDbContext dbContext { get; set; }

        [Parameter]
        public AdvModel Data { get; set; }


        private async Task CreateCategoryAsync()
        {
            if (!form.IsValid())
            {
                return;
            }
            var model = form.GetValue<AdvModel.UpdateModel>();
            var category = dbContext.Advs.FirstOrDefault(x => x.Id == Data.Id);
            category.Url = model.Url;
            category.Image = model.Image[0].Url;
            await dbContext.SaveChangesAsync();
            await CloseAsync();
        }
    }
}
